/*
 * BubbleSortAlgorithm.java
 *
 * Created on 29 de noviembre de 2005, 09:49 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */

package pe.com.nextel.rms;

/**
 *
 * @author marizaga
 */
public class BubbleSortAlgorithm {
    
    /** Creates a new instance of BubbleSortAlgorithm */
    public BubbleSortAlgorithm() {
    }
    
    public static void sort(int a[]) throws Exception {
	for (int i = a.length; --i>=0; ) {
	    boolean swapped = false;
	    for (int j = 0; j<i; j++) {
		if (a[j] > a[j+1]) {
		    int T = a[j];
		    a[j] = a[j+1];
		    a[j+1] = T;
		    swapped = true;
		}
	    }
	    if (!swapped)
		return;
	}
    }
}
